/*
 *  levelUpGame - AStarNode.h
 *  Copyright 2011 W. Reckman. All rights reserved.
 */
#ifndef A_STAR_NODE_H
#define A_STAR_NODE_H

#include "Utils.h"

class AStarNode {
public:
	AStarNode();
	explicit AStarNode( const GridPoint<int>& pos_ );
	explicit AStarNode( const AStarNode& other_ );
	AStarNode( AStarNode* parent_, const GridPoint<int>& pos_ );
	
	AStarNode* getParent() const;
	const GridPoint<int>& getPos() const;
	GridPoint<int>& getPos();
	float getCost() const;
	float getF() const;
	float getG() const;
	float getH() const;
	
	void setParent( AStarNode* parent_ );
	void setPos( const GridPoint<int>& pos_ );
	void setCost( float cost_ );
	void setH( float h_ );
	
	bool operator==( const AStarNode& other_ ) const;
	bool samePosition( const AStarNode& other_ ) const;
	
private:
	AStarNode* parent;
	
	float cost;
	float gCache;
	float hEstimate;
	
	GridPoint<int> pos;
	
	float recalculateG();
};


class AStarNodeFCompare {
public:
	bool operator() ( const AStarNode* lhv, const AStarNode* rhv ) const;
};

#endif /* ! A_STAR_NODE_H */
